#include <iostream>
#include <unistd.h>
#include <pthread.h>

int cnt = 0;

void *Count(void * args)
{

    // pthread_detach(pthread_self());
    uint64_t number = *(uint64_t*)args;
    // uint64_t number = (uint64_t)args;
    while(true)
    {
        // std::cout << "pthread: " << number <<std::endl;
        printf("pthread: %llu\n", number);
        sleep(3);
    }
}

int main()
{
    for(uint64_t i = 0; i < 5; i++)
    {
        pthread_t tid;
        uint64_t* p = new uint64_t(i); 
        pthread_create(&tid, nullptr, Count, p);
        // pthread_create(&tid, nullptr, Count, (void*)i);
    }

    while(true) 
    {
        sleep(1);
    }

    return 0;
}
